package com.captain.special.二叉树;

import com.captain.leetcode.TreeNode;

/**
 * Des:
 *
 * @author XL
 * @Date 2022/4/20 11:02
 */
public class 对称二叉树101 {
    public boolean isSymmetric(TreeNode root) {
        return checkIsSymmetric(root.left, root.right);
    }

    public Boolean checkIsSymmetric(TreeNode node1, TreeNode node2) {
        if (node1 == null && node2 == null) {
            return true;
        }
        if (node1 == null || node2 == null || node1.val != node2.val) {
            return false;
        }
        boolean left = checkIsSymmetric(node1.left, node2.right);
        boolean right = checkIsSymmetric(node1.right, node2.left);
        return left && right;
    }
}
